Rendering Pipeline
Vox’s rendering pipeline centres around the directed acyclic graph (DAG) data structure. Builds begin with constructing a DAG where the children of pages are their layouts (a layout appearing in the DAG as often as it was used), and the parents of non-layout pages are the pages in the collections they depend on. As an illustrative example, the DAG of this site looks like the following:
Then, pages are rendered recursively, with every root page (ie, every page without any parents) having its descendants rendered.
When changes are made, rebuilding can be done selectively:
- A new DAG is constructed.
- The difference is obtained between the old and new DAGs.
- A page is considered modified if it has the same path, but its page is different (not comparing
url
orrendered
).- If a node’s page is the same (excluding
url
orrendered
), it is unchanged.
- If a node’s page is the same (excluding
- A page is considered added if its path appears in the new DAG, but not the old one.
- A page is considered removed if its path appears in the old DAG, but not the new one.
- A page is considered modified if it has the same path, but its page is different (not comparing
- A list of pages needing rendering is computed.
- All pages that were modified need to be rendered.
- Their descendants in the new DAG also need to be rendered.
- If the page is a layout, its parents in the new DAG need to be rendered.
- All pages that were added need to be rendered.
- Their descendants in the new DAG also need to be rendered.
- All pages that were removed need their descendants in the new DAG rendered.
- If the page is a layout, its parents in the new DAG also need to be rendered.
- All pages that were modified need to be rendered.
- The DAGs are merged.
- In the new DAG, all pages not needing rendering are replaced with their rendered counterparts from the old DAG.
- Pages are rendered.